package com.example.administrator.myapplication.Presenter;

import com.example.administrator.myapplication.Bean.AjaxResult;
import com.example.administrator.myapplication.Bean.User;
import com.example.administrator.myapplication.Model.IMineModel;
import com.example.administrator.myapplication.Model.MineModel;
import com.example.administrator.myapplication.View.Fragment.IMineView;

/**
 * Created by Administrator on 2019/10/8 0008.
 */

public class MinePresenter implements IMinePresenter,IMineListener{
    private IMineModel iMineModel;
    private IMineView iMineView;
    public MinePresenter(IMineView iMineView){
        this.iMineModel = new MineModel();
        this.iMineView = iMineView;
    }

    @Override
    public void updateProfile(User user) {
        iMineModel.updateProfile(user,this);
    }



    @Override
    public void getProfile() {
        iMineModel.getProfile(this);
    }

    @Override
    public void profile(User user) {
        iMineView.showProfile(user);
    }

    @Override
    public void error(String error) {
        iMineView.showError(error);

    }
    @Override
    public void success(AjaxResult ajaxResult) {
        if(ajaxResult.getCode()==AjaxResult.SUCCESS_CODE)
            iMineView.showSuccess(ajaxResult.getMsg());
        else
            iMineView.showError(ajaxResult.getMsg());
    }
}
